package com.dong.javaai.controller;

import com.dong.javaai.tools.DateTimeTools;
import com.dong.javaai.tools.WeatherTools;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tools")
public class ToolsController {

    private final ChatClient chatClient;

    public ToolsController(ChatClient.Builder aiClientBuilder) {
        this.chatClient = aiClientBuilder.build();
    }

    @GetMapping("/getDate")
    public ResponseEntity<?> getDate(String prompt) {
        String response = this.chatClient.prompt(prompt).tools(new DateTimeTools()).call().content();
        return ResponseEntity.ok(response);
    }

    @GetMapping("/weather")
    public ResponseEntity<?> getWeather(String prompt) {
        String response = this.chatClient.prompt(prompt).tools(new WeatherTools()).call().content();
        return ResponseEntity.ok(response);
    }

}
